<%@page import="com.solution.common.config.PublicConfig"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="rootPath" value="<%=PublicConfig.ROOT_PATH%>" />
<c:set var="imgRootPath" value="<%=PublicConfig.IMG_ROOT_URL%>" />

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>组织架构选择器</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="${rootPath}/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="${rootPath}/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="${rootPath}/statics/plugins/zTree/css/zTreeStyle/zTreeStyle.css" />

<script type="text/javascript">
	var rootPath = '${rootPath}';
	var imgRootPath = '${imgRootPath}';
</script>
</head>
<body>
	<div class="layui-fluid" style="padding:0px;">
    	<div class="layui-card">
      		<div class="layui-card-body" style="padding: 15px;">
      			<div class="layui-form" lay-filter="org_selector_form" id="org_selector_form">
      				<div class="layui-form-item">
      					<ul id="orgTree" class="ztree"></ul>
      					<input type="hidden" id="tmp_id" name="id" value=""/>
						<input type="hidden" id="tmp_name" name="name" value=""/>
      				</div>
      				<div class="layui-form-item layui-hide">
      					<input type="button" lay-submit lay-filter="btn_confirm" id="btn_confirm" value="确认">
      				</div>
      			</div>
				
			</div>
		</div>
	</div>
	
	<script src="${rootPath}/layuiadmin/layui/layui.all.js"></script>
	<script type="text/javascript" src="${rootPath}/statics/js/jquery.1.11.3.min.js"></script>
	<script src="${rootPath }/statics/plugins/zTree/js/jquery.ztree.all-3.5.min.js"></script>
	
	<script style="text/javascript">
		;!function(){
			var layer = layui.layer;
			var form = layui.form;
			var $ = layui.$;
			var jQuery = layui.$;
			var table = layui.table;
			var upload = layui.upload ;
			
			// 添加选中的组织架构
			/**
			$("#btn_add_all").click(function(){
				var zTree = $.fn.zTree.getZTreeObj('orgTree')
				var selectedNodes = [];
				var nodes = zTree.getCheckedNodes();
				for (var i = 0, l = nodes.length; i < l; i++) {
					var nodeObj = nodes[i];
					if(nodeObj.path.length == 22){
						var data = {"id":nodeObj.id,"orgName":nodeObj.areaName};
						selectedNodes.push(data);
					}
				}
				if(selectedNodes.length > 0 ){
					window.parent.window.clearGetTargetList();
					for(var i = 0; i < selectedNodes.length; i++ ){
						window.parent.window.addAreaToSelectedTable(selectedNodes[i]);
					}
					parent.layer.closeAll();
				}else{
					layer.msg("请选择组织架构",{time:1000});
				}
			});
			*/
			
		}();
		
		
		$(function(){
			var tree = $("#orgTree");
			var setting = {
				async: {
					enable: true,
					url: rootPath + "/org/listOrgForSelector",
					autoParam: ["id", "name"]
				},
				data : {
					simpleData : {
						enable : true,
						idKey : 'id',
						pIdKey : 'parentId',
						rootPId : "1"
					},
					key: {
						name: "orgName"
					}
				},
				callback : {
					onClick : function(event, treeId, treeNode){
						$("#tmp_id").val(treeNode.id);
						$("#tmp_name").val(treeNode.orgName);
					}
				}
			};
			var nodes = [{"id":1,"orgName":"公司组织架构","parentId":0,"isParent":true }];
			var treeObj = $.fn.zTree.init(tree, setting, nodes);
		});
  	</script>
  
  
</body>
</html>


